<div><h4 class="tl">订单信息概览</h4></div>

<a class="btn btn-default"  role="button" href="#/record/{{order.objectId}}">操作记录</a>
<form class="form-horizontal tl">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">订单号:</label>
        <div class="col-sm-10">
           <p class="form-control clearBorder"  ng-bind="order.orderNo"></p>
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">订单状态:</label>
        <div class="col-sm-10">
           <p class="dib form-control clearBorder">{{states[order.state]}}</p>
            <button ng-if ="order.state== '2'" class="btn btn-primary" ng-click="setState()">更改为收款中</button>
            <a class="btn btn-primary" ng-click="editRefund(order,'order')" data-toggle="modal" data-target="#refundModal">退款</a>
        </div>
    </div>

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">下单日期:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{order.createdAt | date:'yyyy-MM-dd HH:mm '}}</p>
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">客户端IP:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{order.clientIp}}</p>
        </div>
    </div>

</form>

<hr>

<div><h4 class="tl">处理信息</h4></div>

<form class="form-inline">
    <div  ng-repeat="remark in order.remarks">
    <div class="col-sm-1"></div>
    <div class="form-group" >
        <label for="exampleInputName2">备注内容:</label>
        <p style="vertical-align: baseline" class="form-control clearBorder">{{remark.text}}</p>
    </div>
    <div class="form-group">
        <label for="exampleInputEmail2">备注人</label>
        <p style="vertical-align: baseline" class="form-control vba clearBorder">{{remark.handler}}</p>
    </div>
     <div class="form-group">
            <label for="exampleInputEmail2">时间</label>
         <p style="vertical-align: baseline" class="form-control clearBorder">{{remark.createdAt | date:'yyyy-MM-dd HH:mm '}}</p>
    </div>
    </div>

    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <a class=" btn btn-primary" ng-click="editObject(model)" data-toggle="modal" data-target="#remarkModal">新增备注</a>
    </div>


</form>


<hr>

<div><h4 class="tl">付款信息</h4></div>

<form class="form-horizontal tl">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">订单金额:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder"  ng-bind="order.cost"></p>
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">应支付金额:</label>
        <div class="col-sm-10">
            <div ng-show="!editBuyCost">
            <p class="form-control ltw  dib mr5 clearBorder"  ng-bind="order.buyCost"></p>
            <button class="btn btn-primary" ng-click="updateBuyCost(order.buyCost)">修改</button>

            </div>
            <div ng-show="editBuyCost">
            <input  type="number" class="ltw  dib form-control " ng-model="order.buyCost">
             <button class="btn btn-primary" ng-click="saveBuyCost(order.buyCost)">保存</button>
            </div>
        </div>
    </div>


    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">支付方式:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{payMethods[order.payMethod]}}</p>
        </div>
    </div>

    <!--<div class="form-group">-->
        <!--<label for="inputPassword3" class="col-sm-2 control-label">待付金额:</label>-->
        <!--<div class="col-sm-10">-->
            <!--<p class="form-control clearBorder">{{payMethods[model.payMethod]}}</p>-->
        <!--</div>-->
    <!--</div>-->

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">待付金额:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{order.buyCost - order.paidAmount}}</p>
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">已付金额:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{order.paidAmount}}</p>
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">运费:</label>
        <div class="col-sm-10">
            <div ng-show="!editFreight">
                <p class="form-control ltw  dib mr5 clearBorder"  ng-bind="order.freight"></p>
                <button class="btn btn-primary" ng-click="updateFreight(order.freight)">修改</button>

            </div>
            <div ng-show="editFreight">
                <input  type="number" class="ltw  dib form-control " ng-model="order.freight">
                <button class="btn btn-primary" ng-click="saveFreight(order.freight)">保存</button>
            </div>
        </div>



    </div>

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">实际运费:</label>
        <div class="col-sm-10">
            <input type="number" class="form-control" ng-model="order.realFreight">
        </div>
    </div>


    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <button class="btn btn-primary" ng-click="save()">保存</button>
    </div>

</form>

<hr>

<div><h4 class="tl">收货人信息</h4></div>

<form class="form-horizontal tl">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">姓名:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.receiverName" />
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">手机:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.receiverPhone" />
        </div>
    </div>


    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">地址:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.receiverAddress" />
        </div>
    </div>



    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">邮箱:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.receiverEmail" />
        </div>
    </div>



    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <a class="btn btn-default"  role="button" href="#/edit-customer/{{order.customerId}}">跳到个人主页</a>
        <button class="btn btn-primary" ng-click="save()">保存</button>
    </div>

</form>

<hr>


<div><h4 class="tl">产品清单</h4></div>

<form class="form-inline">
    <div  ng-repeat="p in order.production">
        <div class="col-sm-1"></div>
        <div class="form-group" >
            <label for="exampleInputName2">产品名:</label>
            <p style="vertical-align: baseline" class="form-control clearBorder">{{p.name}}</p>
        </div>
        <div class="form-group" >
            <label for="exampleInputName2">产品编码:</label>
            <p style="vertical-align: baseline" class="form-control clearBorder">{{p.code}}</p>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">购买价格</label>
            <p style="vertical-align: baseline" class="form-control vba clearBorder">{{p.buyCost}}</p>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">原价</label>
            <p style="vertical-align: baseline" class="form-control vba clearBorder">{{p.cost}}</p>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">优惠价</label>
            <p style="vertical-align: baseline" class="form-control vba clearBorder">{{p.cost - p.buyCost}}</p>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">数量</label>
            <p style="vertical-align: baseline" class="form-control clearBorder">{{p.num}}</p>
        </div>

        <div></div>
        <div class="col-sm-1"></div>
        <div class="form-group">
            <label for="exampleInputEmail2">已发货期数</label>
            <input type="text" ng-model="p.sendNum" style="vertical-align: baseline" class="form-control ">
        </div>



        <div class="form-group">
            <label for="exampleInputEmail2">总发货期数</label>
            <input type="text" ng-model="p.totalNum" style="vertical-align: baseline" class="form-control">
        </div>

        <div class="checkbox">
            <label>
                <input ng-model = "p.pause" type="checkbox"> 暂停发货
            </label>
        </div>



        <div class="form-group" ng-if="p.refund">
            已退款
        </div>

        <a ng-if="!p.refund" class=" btn btn-primary" ng-click="editRefund(p ,'item')" data-toggle="modal" data-target="#refundModal">退款</a>
    </div>


    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <button class="btn btn-primary" ng-click="save()">保存</button>
    </div>
</form>
<hr>



<div><h4 class="tl">发票信息</h4></div>
<form class="form-horizontal tl">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">类型:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.billType" />
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">抬头:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.billHead" />

        </div>
    </div>

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">内容:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="order.billContent" />
        </div>
    </div>

    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <button class="btn btn-primary" ng-click="save()">保存</button>
    </div>
</form>



<hr>


<div><h4 class="tl dib">物流信息</h4> <button class="btn btn-primary" ng-click="addLogistics()">新增物流信息</button></div>
<form class="form-horizontal tl" ng-repeat="l in order.logistics">
    <div class="form-group">
        <label class="col-sm-2 control-label">关联产品:</label>
        <div class="col-sm-10">
        <select class="form-control ltw dib" ng-model="editRelation">
            <option ng-repeat="p in order.production">{{p.name}}</option>
        </select>
            <a class="btn btn-primary btn-xs ml10" ng-click="addProductionToL(editRelation, l)"><span
                    class="glyphicon glyphicon-plus"></span></a>
            <div class="dib">
                <div ng-repeat="p in l.production track by $index" class="tag label btn-info lg dib">
                    <span>{{p}}</span><a ng-click="remove(p, l.production)">
                    <i class="remove ml2 cp glyphicon glyphicon-remove-sign glyphicon-white"></i></a>
                </div>
            </div>
        </div>

    </div>


    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">单号:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="stock" ng-model="l.number" />
        </div>
    </div>

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">运费:</label>
        <div class="col-sm-10">
            <input type="number" class="form-control" name="stock" ng-model="l.freight" />
        </div>
    </div>

    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">创建时间:</label>
        <div class="col-sm-10">
            <p class="form-control clearBorder">{{l.createdAt | date:'yyyy-MM-dd HH:mm'}}</p>
        </div>
    </div>



    <div class="mt20 fix">
        <div class="col-sm-2"></div>
        <button class="btn btn-primary" ng-click="save()">保存</button>
    </div>

</form>


<hr>







<div style="height: 100px"></div>





<div class="modal fade" id="remarkModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-hidden="true">x</button>
                <h3 id="userMgrLabel">备注</h3>
            </div>
            <div class="modal-body">

                <div ng-if="editOrder.remarks.length>0">
                    <h4>历史备注</h4>
                    <table class="table table-striped table-condensed table-bordered table-hover">
                        <thead>
                        <tr style="background-color: #0081c2; color: #FFFFFF">
                            <td>备注</td>
                            <td>操作人</td>
                            <td>时间</td>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="r in editOrder.remarks">
                            <td>{{r.text}}</td>
                            <td>{{r.handler}}</td>
                            <td>{{r.createdAt | date:'yyyy-MM-dd '}}</td>
                        </tr>
                        </tbody>
                    </table>

                </div>

                <h4>新增备注</h4>
                <form name="userForm" class="form-horizontal" role="form">
                    <div class="form-group" >
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea row="3" type="text" class="form-control"   ng-model="newRemark.text">
                            </textarea>
                        </div>
                    </div>

                     <div class="checkbox">
                         <div class="col-sm-2"> </div>
                       <label>
                        <input ng-model = "newRemark.visual" type="checkbox"> 客户端可见
                       </label>
                      </div>


                </form>

            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
                <button class="btn btn-primary"
                        data-dismiss="modal"
                        aria-hidden="true"
                        ng-click="saveRemark(newRemark, order)"
                >确定</button>
            </div>
        </div>
    </div>
</div>




<div class="modal fade" id="refundModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-hidden="true">x</button>
                <h3 id="userMgrLabel">退款</h3>
            </div>
            <div class="modal-body">

                <form name="userForm" class="form-horizontal" role="form">
                    <div class="form-group" >
                        <label class="col-sm-2 control-label">原因</label>
                        <div class="col-sm-10">
                            <textarea row="2" type="text" class="form-control"   ng-model="refund.reason">
                            </textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">账户</label>
                        <div class="col-sm-10">
                            <input type="text" ng-model="refund.account" name="name" class="form-control" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" ng-model="refund.name" name="name" class="form-control" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">退款金额</label>
                        <div class="col-sm-10">
                            <input type="text" ng-model="refund.cost" name="name" class="form-control" >
                        </div>
                    </div>


                </form>

            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
                <button class="btn btn-primary"
                        data-dismiss="modal"
                        aria-hidden="true"
                        ng-click="saveRefund(refund)"
                >确定</button>
            </div>
        </div>
    </div>
</div>

